
/* GCSx
** SPAWN.H
**
** Spawn-point support (starting point for sprite/script)
** Doesn't include any editor-only functionality
** Usually simply referred to as sprites/objects/scripts in the editor
*/

/*****************************************************************************
** Copyright (C) 2003-2006 Janson
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
*****************************************************************************/

#ifndef __GCSx_SPAWN_H_
#define __GCSx_SPAWN_H_

// (always loaded from elsewhere; doesn't cache by itself but only as part of
//  a parent object)
class Spawn {
protected:
    // Becomes name of entity
    // @TODO: not lowercased right now- never used as an index
    std::string name;
    
    // Only script present- spriteless object (if part of layer, blank sprite)
    // Only anim/tile present- sprite with no object
    // Both- sprite+script object
    // Neither- error condition
    class Script* script; // (never locked)
    // Not normally locked, but SpawnEdit can lock them if requested by layer
    class AnimGroup* animgroup;
    class TileSet* tileset;
    int subid; // (which anim or tile to use)

    // IDs unique within world
    int id;
    
    // Position within layer, pixel-based, may be negative
    int x;
    int y;
    
    // @TODO: color

public:
    // ID of zero if loading or clipboard
    Spawn(int newId = 0);
    virtual ~Spawn();

    // Accessors
    const std::string& getName() const { return name; }
    int getX() const { return x; }
    int getY() const { return y; }
    int getId() const { return id; }
    class Script* getScript() { return script; }
    class AnimGroup* getAnimgroup() { return animgroup; }
    class TileSet* getTileset() { return tileset; }
    int getSubid() const { return subid; }
    
    // Load data from file- parent objects should call this
    virtual void load(class FileRead* file, const class World* world) throw_File;
    
    // GAMEPLAY
    
    // Tells spawn to spawn to given layer (optional) and world
    void generate(class Layer* toLayer, class WorldPlay* toWorld);
};

#endif

